"""
系统设置页面类
"""
from ..base_page import BasePage
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select


class SystemSetPage(BasePage):
    url="/crm/index.php?m=setting&a=defaultInfo"
    #定位器
    tx_locator = (By.CLASS_NAME, "avatar")
    xtsz_locator = (By.LINK_TEXT, "系统设置")
    system_name_locator = (By.ID,"name")
    select_sheng_location = (By.CSS_SELECTOR,"#state")
    select_qu_location = (By.CSS_SELECTOR,"#city")
    btn_save_locator=(By.NAME,"submit")
    tips_success_locator=(By.XPATH,"/html/body/div[5]/div[2]")

    def find_systemset(self):  #进入到系统设置页面
        self.click(self.tx_locator)
        self.click(self.xtsz_locator)
    def system_name(self,systemname):  #输入系统名称
        # ele=self.find_element(self.system_name_locator)
        # ele.clear()
        # ele.send_keys(systemname)
        self.send_keys(self.system_name_locator,systemname)
    def select_sheng(self,option_sheng):
        ss_location = self.find_element(self.select_sheng_location)
        ss_obj=Select(ss_location)
        ss_obj.select_by_value(option_sheng)
    def select_qu(self,option_qu):
        sq_location = self.find_element(self.select_qu_location)
        sq_obj=Select(sq_location)
        sq_obj.select_by_value(option_qu)
    def btn_save(self):  #点击保存
        self.click(self.btn_save_locator)
    def tips_success(self):  #获取操作成功的提示
        return self.find_element(self.tips_success_locator).text


